<?php
namespace api\modules\v1\models\shop;

use api\modules\v1\models\Common;
use common\models\Functions;
use common\models\Status;
use yii\base\Exception;

/**
 * This is the model class for table "project_info".
 *
 * @property int $id
 * @property string $name
 */
class GoodsCategory extends \common\models\shop\GoodsCategory
{

    public function getList() {
        try {
            $where['parent_id'] = 0;
            $where['status'] = Status::COMMON_RADIO_YES;
            $where['is_delete'] = Status::COMMON_IS_NOT_DELETE;
            $top = static::getByWhere($where, ["id", "name",'image','icon'],'list_order DESC');

            $result = [];
            foreach ($top as $v) {
                $tmp = [];
                $tmp['id'] = $v['id'];
                $tmp['name'] = $v['name'];
                $tmp['image'] = \common\models\Common::getImages($v['image']);
                $result[] = $tmp;
            }

            return Functions::formatRestAPI(0, '', $result);
        } catch (\yii\db\Exception $ee) {
            return Functions::formatRestAPI(1, '数据异常');
        } catch (Exception $e) {
            return Functions::formatRestAPI(0, '');
        }
    }
}
